package dongze.com.ckdj;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;

import dongze.com.ckdj.data.entity.request.UserRequestBody;
import dongze.com.ckdj.util.MyLog;

public class MainActivity extends Activity {
    private static final String TAG = MainActivity.class.getSimpleName();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        MyLog.d(TAG, "onCreate: " + this);
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        UserRequestBody user = new UserRequestBody();
        user.setUserNo("PK004");
        user.setUserPwd("");

//        Call<ResponseTemplate<User>> call = DataLayer.getDataLayer().login(user);
//        call.enqueue(new Callback<ResponseTemplate<User>>() {
//            @Override
//            public void onResponse(Call<ResponseTemplate<User>> call, Response<ResponseTemplate<User>> response) {
//                MyLog.e(TAG, "onResponse: " + response.body());
//            }
//
//            @Override
//            public void onFailure(Call<ResponseTemplate<User>> call, Throwable t) {
//                MyLog.e(TAG, "onFailure: ", t);
//            }
//        });

//       VehicleNumberRequestBody vehicleNumberRequestBody = new VehicleNumberRequestBody();
//        vehicleNumberRequestBody.setVin("123");
//        Call<ResponseTemplate<List<VehicleNumberResponse>>> call = DataLayer.getDataLayer().getVehicleNumber(vehicleNumberRequestBody);
//        call.enqueue(new Callback<ResponseTemplate<List<VehicleNumberResponse>>>() {
//            @Override
//            public void onResponse(Call<ResponseTemplate<List<VehicleNumberResponse>>> call, Response<ResponseTemplate<List<VehicleNumberResponse>>> response) {
//                MyLog.d(TAG, "onResponse: ");
//            }
//
//            @Override
//            public void onFailure(Call<ResponseTemplate<List<VehicleNumberResponse>>> call, Throwable t) {
//                MyLog.e(TAG, "onFailure: ", t);
//            }
//        });

//        Call<ResponseTemplate<VehicleInformationDetail>> call = DataLayer.getDataLayer().getVehicleInfationDetail("123");
//        call.enqueue(new Callback<ResponseTemplate<VehicleInformationDetail>>() {
//            @Override
//            public void onResponse(Call<ResponseTemplate<VehicleInformationDetail>> call, Response<ResponseTemplate<VehicleInformationDetail>> response) {
//                MyLog.d(TAG, "onResponse: ");
//            }
//
//            @Override
//            public void onFailure(Call<ResponseTemplate<VehicleInformationDetail>> call, Throwable t) {
//                MyLog.e(TAG, "onFailure: ", t);
//            }
//        });

//        Call<ResponseTemplate<List<OperationsResponse>>> call = DataLayer.getDataLayer().getOperations("123", "100");
//        call.enqueue(new Callback<ResponseTemplate<List<OperationsResponse>>>() {
//            @Override
//            public void onResponse(Call<ResponseTemplate<List<OperationsResponse>>> call, Response<ResponseTemplate<List<OperationsResponse>>> response) {
//                MyLog.d(TAG, "onResponse: ");
//            }
//
//            @Override
//            public void onFailure(Call<ResponseTemplate<List<OperationsResponse>>> call, Throwable t) {
//                MyLog.d(TAG, "onFailure: ");
//            }
//        });
//        DaoMaster.DevOpenHelper devOpenHelper = new DaoMaster.DevOpenHelper(getApplicationContext(), "image.db");
//        DaoMaster daoMaster = new DaoMaster(devOpenHelper.getWritableDb());
//        DaoSession session = daoMaster.newSession();
//        ImageDao imageDao = session.getImageDao();
//        Image image = new Image();
//        image.setFilePath("fdsasdf");
//        imageDao.insert(image);
//
//        List<Image> images = imageDao.queryBuilder().build().list();
//        MyLog.d(TAG, "onCreate: " + images);

//        DataLayer.getDataLayer().uploadImage(new File("/sdcard/DCIM/Camera/IMG_20170712_180836.jpg"))
//                .enqueue(new Callback<UploadImageResponse>() {
//                    @Override
//                    public void onResponse(Call<UploadImageResponse> call, Response<UploadImageResponse> response) {
//                        MyLog.d(TAG, "onResponse: ");
//                    }
//
//                    @Override
//                    public void onFailure(Call<UploadImageResponse> call, Throwable t) {
//                        MyLog.d(TAG, "onFailure: ");
//                    }
//                });

//        MapUtil.uploadImage(new File("/sdcard/DCIM/Camera/IMG_20170712_180836.jpg"))
//                .subscribeWith(new Observer<String>() {
//                    @Override
//                    public void onSubscribe(Disposable d) {
//
//                    }
//
//                    @Override
//                    public void onNext(String value) {
//                        MyLog.d(TAG, "onNext: ");
//                    }
//
//                    @Override
//                    public void onError(Throwable e) {
//                        MyLog.e(TAG, "onError: ", e);
//                    }
//
//                    @Override
//                    public void onComplete() {
//
//                    }
//                });
    }

    @Override
    protected void onDestroy() {
        MyLog.d(TAG, "onDestroy: " + this);
        super.onDestroy();
    }
}
